home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / misc / emu / amiSPIMsrc.lha / cl-except.h < prev    next >
C/C++ Source or Header  |  1994-02-06  |  4KB  |  119 lines

  1. /* SPIM S20 MIPS Cycle Level simulator.
  2.    Definitions for the SPIM S20 Cycle Level Simulator (SPIM-CL).
  3.    Copyright (C) 1991-1992 by Anne Rogers (amr@cs.princeton.edu) and
  4.    Scott Rosenberg (scottr@cs.princeton.edu)
  5.    ALL RIGHTS RESERVED.
  6.  
  7.    SPIM-CL is distributed under the following conditions:
  8.  
  9.      You may make copies of SPIM-CL for your own use and modify those copies.
  10.  
  11.      All copies of SPIM-CL must retain our names and copyright notice.
  12.  
  13.      You may not sell SPIM-CL or distributed SPIM-CL in conjunction with a
  14.      commerical product or service without the expressed written consent of
  15.      Anne Rogers.
  16.  
  17.    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  18.    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  19.    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20.    PURPOSE.
  21. */
  22.  
  23. #ifndef amiga
  24. #include <syscall.h>
  25. #else
  26. #include <sys/syscall.h>
  27. #endif
  28. #include <signal.h>
  29.  
  30. /* gdb-style for tracking each signal */
  31. typedef struct signal_desc
  32. {
  33.   char *signame;
  34.   short stats;        /* bit 0 --> pass signal to simulated program
  35.              * bit 1 --> print if signal is seen
  36.              * bit 2 --> stop if signal is seen */
  37.   char *desc;        /* short description of signal */
  38. } signal_desc;
  39.  
  40. extern signal_desc siginfo[NSIG];
  41.  
  42. #define DESC(sig)    (siginfo[sig].desc)
  43. #define STOP(sig)    (siginfo[sig].stats & 0x4 ? 1 : 0)
  44. #define PRINT(sig)    (siginfo[sig].stats & 0x2 ? 1 : 0)
  45. #define PASS(sig)    (siginfo[sig].stats & 0x1 ? 1 : 0)
  46. #define SET_STOP(sig,flag)                        \
  47.   siginfo[sig].stats = (flag ? siginfo[sig].stats | 0x4 :        \
  48.                siginfo[sig].stats & ~0x4)
  49. #define SET_PRINT(sig,flag)                        \
  50.     siginfo[sig].stats = (flag ? siginfo[sig].stats | 0x2 :    \
  51.                  siginfo[sig].stats & ~0x2)
  52. #define SET_PASS(sig,flag)                        \
  53.     siginfo[sig].stats = (flag ? siginfo[sig].stats | 0x1 :    \
  54.                  siginfo[sig].stats & ~0x1)
  55.  
  56.  
  57. /* implemented as discussed in 4.3BSD UNIX Operating System, Leffler, */
  58. /* McKusick, Karels, Quarterman, Addison-Wesley, New York, 1989. */
  59. typedef struct spim_proc
  60. {
  61.   int p_sig;            /* list of pending signals for current proc */
  62.   int p_sigmask;        /* which signals to mask */
  63.   int p_sigcatch;        /* which signals to catch */
  64.   int p_cursig;            /* signal currently being processed */
  65.   struct sigvec sv[NSIG];    /* handler information for each signal */
  66.   mem_addr tramp_addr[NSIG];    /* trampoline addr for each handler */
  67. } spim_proc;
  68.  
  69. spim_proc proc;            /* spim's signal tracking structure */
  70.  
  71. #define HANDLE(sig)        (proc.sv[sig].sv_handler)
  72. #define HANDLE_MASK(sig)    (proc.sv[sig].sv_mask)
  73. #define TRAMP(sig)        (proc.tramp_addr[sig])
  74. #define MASK            proc.p_sigmask
  75. #define CATCH            proc.p_sigcatch
  76.  
  77.  
  78.  
  79. typedef struct excpt_desc
  80. {
  81.   char *excptname;
  82.   int sig;        /* if mappable to signal, what is signal ? */
  83.   int freq;        /* how many times has it occurred */
  84. } excpt_desc;
  85.  
  86. extern excpt_desc excpt_handler[];
  87.  
  88. #define EXCPT_STR(x)    (excpt_handler[x].excptname)
  89. #define EXCPT_COUNT(x)    (excpt_handler[x].freq)
  90.  
  91.  
  92.  
  93. /* Exported Functions: */
  94. #ifdef __STDC__
  95. void dosigreturn (mem_addr sigptr);
  96. void initialize_catch_signals (void);
  97. void initialize_sighandlers (void);
  98. void initialize_excpt_counts (void);
  99. int process_excpt (void);
  100. void print_except_stats (void);
  101. void print_signal_status (int sig);
  102. #else
  103. void dosigreturn ();
  104. void initialize_catch_signals ();
  105. void initialize_sighandlers ();
  106. void initialize_excpt_counts ();
  107. int process_excpt ();
  108. void print_except_stats ();
  109. void print_signal_status ();
  110. #endif
  111.  
  112.  
  113. extern mem_addr breakpoint_reinsert; /* !0 -> reinsert break at this address */
  114.                 /* in IF because we've just processed it */
  115. #define ALL_SIGNALS 100001        /* when passed as first parameter */
  116.                     /* to print_signal_status, print */
  117.                     /* all signals' information. */
  118.  
  119.